﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNet.Random.IpAddress
{
    /// <summary>
    /// ipv4随机类，实现了接口IStringRandService
    /// </summary>
    public class Ipv4RandService : DotNet.Random.Interface.IStringRandService
    {
        /// <summary>
        /// Rands this instance.
        /// 随机生成字符串方法
        /// 映射到虚方法中，扩展时，可重写
        /// </summary>
        /// <returns>
        /// 返回字符串类型
        /// </returns>
        public virtual string Rand()
        {
            var res = new List<int>();
            var intRand = new DotNet.Random.Int.IntRandService();
            for (int i = 1; i < 255; i++)
            {
                intRand.Serial.Add(i);
            }
            for (int i = 0; i < 4; i++)
            {
                res.Add(intRand.Rand());
                System.Threading.Thread.Sleep(200);
            }
            var str = string.Join(".", res);
            return str;
        }
    }
}
